<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://www.rapid-framework.org.cn/rapid" prefix="rapid" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"  %>
<%@ taglib  uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> 
<rapid:override name="frame-content">
	
	<blockquote class="layui-elem-quote">
					<span class="layui-breadcrumb" lay-separator="/"> <a
						href="/admin">首页</a> <a><cite>文章列表</cite></a>
					</span>
				</blockquote>
				
				<div class="layui-tab layui-tab-card">
				
					<form id="form" action="${pageUrlPrefix}1" method="post" name="form"> 
					标题过滤: <input  style=" margin:10px;height:23px" id="articleTitle" name="articleTitle"  placeholder="标题过滤" value="${param.articleTitle}"/>
					<select id="categoryId" name="categoryId"  style=" height:23px">
					 	<option  value=-1>分类</option>
                 	 <c:forEach var="n" items="${categoryList}">
                		<option value="${n.categoryId}">${n.categoryName}</option>
                     </c:forEach>
				 	</select>
				 	<input type="hidden" id="tagId" name="tagId" value="${tagId}">
					&nbsp; &nbsp;
					
					 <select id="articleStatus" name="articleStatus" style=" height:23px">
				 	 <option value="" >文章状态</option>
				 	 <option value="1"  >已发布</option>
				 	 <option value="0" >草稿</option>
				 	 </select>
				 	 &nbsp; &nbsp;
				 	 <button>查询</button>
				 	  
						<input type="hidden" name="currentUrl" id="currentUrl" value="">
						<table class="layui-table">
							<colgroup>
								<col width="300">
								<col width="150">
								<col width="100">
								<col width="150">
								<col width="100">
								<col width="50">
							</colgroup>
							<thead>
								<tr>
									<th>标题</th>
									<th>所属分类</th>
									<th>状态</th>
									<th>发布时间</th>
									<th>操作</th>
									<th>id</th>
								</tr>
							</thead>
							<tbody>
								
								
								
								
								
								
								
								<c:forEach var="a" items="${pageInfo.list}">
								
								<tr>
									<td><a href="/article/${a.articleId }" target="_blank"> ${a.articleTitle }</a></td>
										<td>
										<!-- ${fn:length(List)} 可以获得list的长度 -->
									<c:if test="${fn:length(a.categoryList)!=0}">
										<c:forEach var="c" items="${a.categoryList}">
										<a href="/category/${c.categoryId}" target="_blank">${c.categoryName}</a>&nbsp; 
										</c:forEach>
									</c:if>
									<c:if test="${fn:length(a.categoryList)==0}">
									<a  target="_blank">未分类</a>&nbsp; 
									</c:if>
									
									</td>
									<td>
									<c:if test="${a.articleStatus==0 }">
									<a href="/admin/article/status/${a.articleStatus }"> <span style="color: #FF5722;">草稿</span></a>
									</c:if>
									<c:if test="${a.articleStatus==1 }">
									<a href="/admin/article/status/${a.articleStatus }"> <span style="color: #5FB878;"> 已发布 </span></a>
									</c:if>
									</td>
									<td><fmt:formatDate value="${a.articleCreateTime}" pattern="yyyy-MM-dd hh:mm"/> </td>
									<td><a href="article/edit/${a.articleId }" class="layui-btn layui-btn-mini">编辑</a> 
										<a href="javascript:void(0)" onclick="deleteArticle('${a.articleId }')" class="layui-btn layui-btn-danger layui-btn-mini">删除</a>
									</td>
									<td>${a.articleId}</td>
								</tr>
								</c:forEach>
							</tbody>
						</table>
					</form>
					<%@ include file="../page.jsp" %>
				</div>
				<rapid:override name="frame-footer-script">
				<script>
				//删除文章
				function deleteArticle(id) {
				    if(confirmDelete()==true){
				        $.ajax({
				            async: false,
				            type: "POST",
				            url:'article/delete/'+id,
				            contentType : "application/x-www-form-urlencoded; charset=utf-8",
				            dataType: "text",
				            complete:function () {
				                window.location.reload();
				            }
				        })
				    }
				}
				$(function(){
					if("${categoryId}"!="")
					$("#categoryId").val("${categoryId}");
					if("${articleStatus}"!="")
						$("#articleStatus").val("${articleStatus}");
				});
				
				</script>
				</rapid:override>
	
</rapid:override>
<%@ include file="../framework.jsp" %>